\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f3\b0\i0\ul0\fs28 CC preprocessor compiling UNIX utilities\
\
Q: The following code snippet is excerpted from a Bourne shell script which attempts to determine how to invoke the C preprocessor on any given UNIX platform. The script will create a file called testcpp.c and run the C preprocessor on that file redirecting the output to testcpp.out. When I run this script on the NeXT it incorrectly inserts a space in the output file "
\f0\fs24 abc +xyz
\f3\fs28 ". This causes the test which confirms "cc -E" as the correct invokation to fail. Is this a bug in your C preprocessor?\
\
\i \
\f0\i0\fs24 : see how we invoke the C preprocessor\
echo " "\
echo "Checking to see how your C preprocessor is invoked..."\
cat <<'EOT' >testcpp.c\
#define ABC abc\
#define XYZ xyz\
ABC+XYZ\
EOT\
echo 'Maybe "cc -E" will work...'\
cc -E testcpp.c >testcpp.out 2>&1\
if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
echo "Yup, it does."\
cpp='cc -E'\
else\
echo 'Nope...maybe "cc -P" will work...'\
cc -P testcpp.c >testcpp.out 2>&1\
if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
echo "Yup, that does."\
\f3\fs28 \
\
A: The space inserted before the "+xyz" follows the behavior specified by ANSI C. If you want the old behavior of standard UNIX compilers, use the
\f0\fs24 -traditional
\f3\fs28 flag. The man page on cc(1) shows a large number of useful compiler flags in addition to
\f0\fs24 -traditional
\f3\fs28 . The flags
\f0\fs24 -bsd
\f3\fs28 and
\f0\fs24 -fwritable-strings
\f3\fs28 may also be needed when compiling old UNIX programs.\